package edu.nyp.locationservicesapp.utils;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.support.v4.content.FileProvider;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import java.io.File;
import java.util.List;

/**
 * 应用程序相关操作
 * User:Gaolei  gurecn@gmail.com
 * Date:2017/12/6
 * I'm glad to share my knowledge with you all.
 */
public class AppUtils {
	/**
	 * 获得当前所在进程的进程名<br>
	 */
	public synchronized static String getCurrentProcessName(Context cxt) {
		ActivityManager actMgr = (ActivityManager) cxt.getSystemService(Context.ACTIVITY_SERVICE);
		if (actMgr == null) {
			return null;
		}
		List<RunningAppProcessInfo> runningAppProcesses = actMgr.getRunningAppProcesses();
		if (runningAppProcesses == null) {
			return null;
		}
		int pid = android.os.Process.myPid();
		for (RunningAppProcessInfo appProcess : runningAppProcesses) {
			if (appProcess != null && appProcess.pid == pid) {
				return appProcess.processName;
			}
		}
		return null;
	}
}
